Create a new entity of the requested type.
Syntax
Visual Basic (Declaration) | |
---|
Public Overloads Function CreateEntity(Of T As Class)( _
ByVal entitySetName As String _
) As T |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As EntityManager
Dim entitySetName As String
Dim value As T
value = instance.CreateEntity(Of T)(entitySetName) |
Parameters
- entitySetName
- Name of the entity set for the new entity
Type Parameters
- T
- Entity type
Return Value
A new instance of the specified entity type
Example
C# | Copy Code |
---|
DomainModelEntityManager mgr = new DomainModelEntityManager();
// Retrieve an order
Order order = mgr.Orders.FirstOrNullEntity(o=> o.OrderID == 1);
// Retrieve a product
Product product = mgr.Products.FirstOrNullEntity(p => p.ProductID == 1);
// Create an OrderDetail
OrderDetail dtl = mgr.CreateEntity<OrderDetail>();
// assign key fields
dtl.OrderSummary = order;
dtl.Product = product;
// add the OrderDetail to the EntityManager cache
DebugFns.WriteLine("entity state before add = " + dtl.EntityState);
dtl.AddToManager();
DebugFns.WriteLine("entity state after add = " + dtl.EntityState); |
Remarks
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also